package com.orange.score.network;

import android.util.Log;
import com.orange.score.constants.LanguageType;
import com.orange.score.constants.ScoreType;
import com.orange.score.model.index.OddsType;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.BasicResponseHandler;
import org.apache.http.impl.client.DefaultHttpClient;

public class ScoreNetworkRequest
{
  public static final int INDEX_LEAGUE_COUNT = 3;
  public static final int INDEX_LEAGUE_ID = 1;
  public static final int INDEX_LEAGUE_IS_TOP = 2;
  public static final int INDEX_LEAGUE_NAME = 0;
  public static final int INDEX_MATCH_AWAY_TEAM_FIRST_HALF_SCORE = 10;
  public static final int INDEX_MATCH_AWAY_TEAM_NAME = 6;
  public static final int INDEX_MATCH_AWAY_TEAM_RED = 12;
  public static final int INDEX_MATCH_AWAY_TEAM_SCORE = 8;
  public static final int INDEX_MATCH_AWAY_TEAM_YELLOW = 14;
  public static final int INDEX_MATCH_CROWN_CHUPAN = 15;
  public static final int INDEX_MATCH_DATE = 3;
  public static final int INDEX_MATCH_HOME_TEAM_FIRST_HALF_SCORE = 9;
  public static final int INDEX_MATCH_HOME_TEAM_NAME = 5;
  public static final int INDEX_MATCH_HOME_TEAM_RED = 11;
  public static final int INDEX_MATCH_HOME_TEAM_SCORE = 7;
  public static final int INDEX_MATCH_HOME_TEAM_YELLOW = 13;
  public static final int INDEX_MATCH_ID = 0;
  public static final int INDEX_MATCH_LEAGUE_ID = 1;
  public static final int INDEX_MATCH_START_DATE = 4;
  public static final int INDEX_MATCH_STATUS = 2;
  public static final int INDEX_REALINDEX_COMPANY_HAVE_DAXIAO = 3;
  public static final int INDEX_REALINDEX_COMPANY_HAVE_OUPEI = 4;
  public static final int INDEX_REALINDEX_COMPANY_HAVE_YAPEI = 2;
  public static final int INDEX_REALINDEX_COMPANY_ID = 0;
  public static final int INDEX_REALINDEX_COMPANY_NAME = 1;
  public static final int INDEX_REALINDEX_COUNT = 5;
  public static final int INDEX_REALINDEX_DAXIAO_BIG_CHUPAN = 4;
  public static final int INDEX_REALINDEX_DAXIAO_BIG_ODDS = 7;
  public static final int INDEX_REALINDEX_DAXIAO_CHUPAN = 3;
  public static final int INDEX_REALINDEX_DAXIAO_INSTANT_CHUPAN = 6;
  public static final int INDEX_REALINDEX_DAXIAO_SMALL_CHUPAN = 5;
  public static final int INDEX_REALINDEX_DAXIAO_SMALL_ODDS = 8;
  public static final int INDEX_REALINDEX_LEAGUE_ID = 0;
  public static final int INDEX_REALINDEX_LEAGUE_LEVEL = 2;
  public static final int INDEX_REALINDEX_LEAGUE_NAME = 1;
  public static final int INDEX_REALINDEX_LEAGUE_NUM = 3;
  public static final int INDEX_REALINDEX_MATCH_AWAY_NAME = 4;
  public static final int INDEX_REALINDEX_MATCH_AWAY_SCORE = 7;
  public static final int INDEX_REALINDEX_MATCH_HOME_NAME = 3;
  public static final int INDEX_REALINDEX_MATCH_HOME_SCORE = 6;
  public static final int INDEX_REALINDEX_MATCH_ID = 0;
  public static final int INDEX_REALINDEX_MATCH_LEAGUE_ID = 1;
  public static final int INDEX_REALINDEX_MATCH_NUM = 8;
  public static final int INDEX_REALINDEX_MATCH_STATUS = 5;
  public static final int INDEX_REALINDEX_MATCH_TIME = 2;
  public static final int INDEX_REALINDEX_ODDS_COMPANY_ID = 1;
  public static final int INDEX_REALINDEX_ODDS_FIELD_NUM = 9;
  public static final int INDEX_REALINDEX_ODDS_ID = 2;
  public static final int INDEX_REALINDEX_ODDS_MATCH_ID = 0;
  public static final int INDEX_REALINDEX_OUPEI_AWAY_WIN_CHUPEI = 5;
  public static final int INDEX_REALINDEX_OUPEI_AWAY_WIN_INSTANT = 8;
  public static final int INDEX_REALINDEX_OUPEI_DRAW_CHUPEI = 4;
  public static final int INDEX_REALINDEX_OUPEI_DRAW_INSTANT = 7;
  public static final int INDEX_REALINDEX_OUPEI_HOME_WIN_CHUPEI = 3;
  public static final int INDEX_REALINDEX_OUPEI_HOME_WIN_INSTANT = 6;
  public static final int INDEX_REALINDEX_YAPEI_AWAY_TEMA_CHUPAN = 5;
  public static final int INDEX_REALINDEX_YAPEI_AWAY_TEMA_ODDS = 8;
  public static final int INDEX_REALINDEX_YAPEI_CHUPAN = 3;
  public static final int INDEX_REALINDEX_YAPEI_HOME_TEAM_CHUPAN = 4;
  public static final int INDEX_REALINDEX_YAPEI_HOME_TEAM_ODDS = 7;
  public static final int INDEX_REALINDEX_YAPEI_INSTANT_CHUPAN = 6;
  public static final int INDEX_REALTIME_MATCH_AWAY_CANTONESE_NAME = 3;
  public static final int INDEX_REALTIME_MATCH_AWAY_IMAGE_URL = 9;
  public static final int INDEX_REALTIME_MATCH_AWAY_NAME = 1;
  public static final int INDEX_REALTIME_MATCH_AWAY_RANK = 7;
  public static final int INDEX_REALTIME_MATCH_AWAY_SCORE = 11;
  public static final int INDEX_REALTIME_MATCH_FIELD_MAX_COUNT = 13;
  public static final int INDEX_REALTIME_MATCH_FIELD_MIN_COUNT = 12;
  public static final int INDEX_REALTIME_MATCH_HAS_LINEUP = 12;
  public static final int INDEX_REALTIME_MATCH_HOME_CANTONESE_NAME = 2;
  public static final int INDEX_REALTIME_MATCH_HOME_IMAGE_URL = 8;
  public static final int INDEX_REALTIME_MATCH_HOME_NAME = 0;
  public static final int INDEX_REALTIME_MATCH_HOME_RANK = 6;
  public static final int INDEX_REALTIME_MATCH_HOME_SCORE = 10;
  public static final int INDEX_REALTIME_MATCH_STATUS = 4;
  public static final int INDEX_REALTIME_MATCH_TIME = 5;
  public static final int INDEX_REALTIME_ODDS_CHANGE_FIELD_NUM = 5;
  public static final int INDEX_REALTIME_ODDS_COMPANY_ID = 1;
  public static final int INDEX_REALTIME_ODDS_INSTANT_AWAY = 4;
  public static final int INDEX_REALTIME_ODDS_INSTANT_HOME = 3;
  public static final int INDEX_REALTIME_ODDS_INSTANT_PANKOU = 2;
  public static final int INDEX_REALTIME_ODDS_MATCH_ID = 0;
  public static final int INDEX_REALTIME_SCORE_AWAY_TEAM_FIRST_HALF_SCORE = 7;
  public static final int INDEX_REALTIME_SCORE_AWAY_TEAM_RED = 9;
  public static final int INDEX_REALTIME_SCORE_AWAY_TEAM_SCORE = 5;
  public static final int INDEX_REALTIME_SCORE_AWAY_TEAM_YELLOW = 11;
  public static final int INDEX_REALTIME_SCORE_DATE = 2;
  public static final int INDEX_REALTIME_SCORE_HOME_TEAM_FIRST_HALF_SCORE = 6;
  public static final int INDEX_REALTIME_SCORE_HOME_TEAM_RED = 8;
  public static final int INDEX_REALTIME_SCORE_HOME_TEAM_SCORE = 4;
  public static final int INDEX_REALTIME_SCORE_HOME_TEAM_YELLOW = 10;
  public static final int INDEX_REALTIME_SCORE_MATCHID = 0;
  public static final int INDEX_REALTIME_SCORE_START_DATE = 3;
  public static final int INDEX_REALTIME_SCORE_STATUS = 1;
  private static final int LEVEL_FIELD = 3;
  private static final int LEVEL_RECORD = 2;
  private static final int LEVEL_SEGMENT = 1;
  public static final int MATCH_FIELD_MAX_COUNT = 16;
  public static final int MATCH_FIELD_MIN_COUNT = 15;
  public static final int REALTIME_SCORE_FILED_COUNT = 12;
  public static final int SEGMENT_REALINDEX_LEAGUE = 0;
  public static final int SEGMENT_REALINDEX_MATCH = 1;
  public static final int SEGMENT_REALINDEX_ODDS = 2;
  public static final int SEGMENT_REALINDEX_ODDS_COUNT = 3;
  public static final int SEGMENT_REALTIME_LEAGUE = 1;
  public static final int SEGMENT_REALTIME_MATCH = 2;
  public static final int SEGMENT_REALTIME_MATCH_NUM = 3;
  public static final int SEGMENT_REALTIME_SERVER_TIME = 0;
  public static final String SEP_FIELD = "\\^";
  public static final String SEP_RECORD = "\\!";
  public static final String SEP_SEGMENT = "\\$\\$";
  private static final String TAG = ScoreNetworkRequest.class.getName();

  public static String[] getAllMatch(LanguageType paramLanguageType, ScoreType paramScoreType)
  {
    Object[] arrayOfObject = new Object[2];
    arrayOfObject[0] = Integer.valueOf(paramLanguageType.intValue());
    arrayOfObject[1] = Integer.valueOf(paramScoreType.intValue());
    return scoreHttpGet(String.format("http://bf.bet007.com/phone/schedule.aspx?lang=%d&type=%d", arrayOfObject), 1);
  }

  public static String[] getFinishMatch(LanguageType paramLanguageType, String paramString)
  {
    Object[] arrayOfObject = new Object[2];
    arrayOfObject[0] = Integer.valueOf(paramLanguageType.intValue());
    arrayOfObject[1] = paramString;
    String str = String.format("http://bf.bet007.com/phone/scheduleByDate.aspx?lang=%d&date=%s", arrayOfObject);
    Log.i(TAG, "url=" + str);
    return scoreHttpGet(str, 1);
  }

  public static String[] getIndexCompany()
  {
    return scoreHttpGet(String.format("http://bf.bet007.com/phone/Company.aspx", new Object[0]), 2);
  }

  public static String[] getMatchDetail(String paramString)
  {
    Object[] arrayOfObject = new Object[1];
    arrayOfObject[0] = paramString;
    return scoreHttpGet(String.format("http://bf.bet007.com/phone/ScheduleDetail.aspx?ID=%s", arrayOfObject), 3);
  }

  public static String[] getMatchLiveChange()
  {
    return scoreHttpGet(String.format("http://bf.bet007.com/phone/LiveChange.aspx", new Object[0]), 2);
  }

  public static String[] getOddsData(String paramString1, String paramString2, LanguageType paramLanguageType, ScoreType paramScoreType, OddsType paramOddsType)
  {
    Object[] arrayOfObject = new Object[5];
    arrayOfObject[0] = paramString1;
    arrayOfObject[1] = paramString2;
    arrayOfObject[2] = Integer.valueOf(paramLanguageType.intValue());
    arrayOfObject[3] = Integer.valueOf(paramScoreType.intValue());
    arrayOfObject[4] = Integer.valueOf(paramOddsType.intValue());
    return scoreHttpGet(String.format("http://bf.bet007.com/phone/Odds.aspx?Date=%s&companyID=%s&lang=%s&type=%s&odds=%s", arrayOfObject), 1);
  }

  public static String[] getOddsLiveChange(OddsType paramOddsType)
  {
    Object[] arrayOfObject = new Object[1];
    arrayOfObject[0] = Integer.valueOf(paramOddsType.intValue());
    return scoreHttpGet(String.format("http://bf.bet007.com/phone/OddsChange.aspx?odds=%s", arrayOfObject), 2);
  }

  public static String httpGet(String paramString)
  {
    DefaultHttpClient localDefaultHttpClient = new DefaultHttpClient();
    HttpGet localHttpGet = new HttpGet(paramString);
    BasicResponseHandler localBasicResponseHandler = new BasicResponseHandler();
    String str = null;
    try
    {
      Log.d(TAG, "Send http request: " + paramString);
      str = (String)localDefaultHttpClient.execute(localHttpGet, localBasicResponseHandler);
      Log.d(TAG, "Get http response: " + str);
      return str;
    }
    catch (Exception localException)
    {
      Log.e(TAG, "catch exception while send http request " + localException.toString(), localException);
    }
  }

  public static String[] scoreHttpGet(String paramString, int paramInt)
  {
    Object localObject;
    String str = httpGet(paramString);
    if (str == null)
    {
      localObject = null;
      return localObject;
    }
    String[] arrayOfString = (String[])null;
    if (paramInt == 1)
      arrayOfString = str.split("\\$\\$");
    while (true)
    {
      while (true)
      {
        while (true)
        {
          while (true)
            localObject = arrayOfString;
          if (paramInt != 2)
            break;
          arrayOfString = str.split("\\!");
        }
        if (paramInt != 3)
          break;
        arrayOfString = str.split("\\^");
      }
      Log.e(TAG, "Score Http Get But incorrect Level");
    }
  }
}